body {
    background: #DBC8BD;
    font-family: "Montserrat", Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
    scroll-behavior: auto;
    /* Prevent text selection and highlighting on mobile */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Prevent long press context menu */
    -webkit-context-menu: none;
    context-menu: none;
}

/* Apply text selection prevention to all elements by default */
*, *::before, *::after {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Comprehensive mobile browser text selection prevention */
html, body {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-text-size-adjust: none !important;
    -moz-text-size-adjust: none !important;
    -ms-text-size-adjust: none !important;
    text-size-adjust: none !important;
}

/* Prevent selection on all text elements */
h1, h2, h3, h4, h5, h6, p, span, div, a, label {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Prevent selection and highlighting on images */
img {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    pointer-events: none !important;
    -webkit-user-drag: none !important;
    -khtml-user-drag: none !important;
    -moz-user-drag: none !important;
    -o-user-drag: none !important;
    user-drag: none !important;
}

/* Allow text selection only for actual input fields */
input[type="text"]:focus, 
input[type="email"]:focus, 
input[type="tel"]:focus, 
textarea:focus {
    -webkit-user-select: text !important;
    -khtml-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
}

/* Game-specific prevention */
#game-canvas, #controls-container, canvas {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Disable selection on interactive elements */
.btn, button, input[type="submit"], input[type="button"], .question-container div {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    outline: none !important;
}

/* Additional mobile-specific prevention */
@media (max-width: 768px) {
    * {
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
        -webkit-appearance: none !important;
    }
    
    /* Prevent text selection bubble on mobile Safari */
    *::selection {
        background: transparent !important;
    }
    
    *::-moz-selection {
        background: transparent !important;
    }
    
    *::-webkit-selection {
        background: transparent !important;
    }
}

/* Game page specific background */
body.game-active {
    background: black;
}

html {
    scroll-behavior: auto;
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 0px;
}

.title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0px auto 30px auto;
    color: #833909;
    text-align: center;
}

#register-page, #intro-page {
    width: 85%;
    max-width: 420px;
    margin: 30px auto;
    background: #ffffff;
    text-align: center;
    padding-top: 15px;
    padding-bottom: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    min-height: 86vh;
}

#register-form {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#register-page h2 {
    font-size: 1rem;
    font-weight: 400;
    margin-top: 10px;
    margin-bottom: 20px;
    color: #000000;
}

#register-page input,
#register-page select {
    width: 80%;
    padding: 15px;
    margin: 5px 0 15px 0;
    border-radius: 10px;
    border: none;
    font-size: 16px;
    font-family: "Montserrat", Arial, Helvetica, sans-serif;
    box-sizing: border-box;
    text-align: center;
    border: 1px solid #833909;
    font-weight: 500;
}

#register-page input::placeholder {
    color: #833909;
    opacity: 0.5;
}

/* Override autofill styling */
#register-page input:-webkit-autofill,
#register-page input:-webkit-autofill:hover,
#register-page input:-webkit-autofill:focus,
#register-page input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #ffffff inset !important;
    -webkit-text-fill-color: #833909 !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* For Firefox and other browsers */
#register-page input:autofill {
    background-color: #EEE4DE !important;
    color: #833909 !important;
}

#register-page label {
    font-weight: bold;
    margin-bottom: 2px;
    display: block;
    font-size: 0.8em;
    font-family: "Montserrat", Arial, Helvetica, sans-serif;
    color: #000000;
}

#register-page button {
    margin-top: 15px;
    margin-bottom: 5px;
}

#register-page {
    margin-bottom: 50px;
}

#intro-page .intro-question h1 {
    color: #000000;
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 40px;
    font-weight: 500;
}

#intro-page .intro-question {
    margin-top: 15vh;
}

#intro-page h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0px auto 30px auto;
    color: #833909;
    text-align: center;
}

.question-container {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    width: 90%;
    max-width: 420px;
    margin: 20px auto; /* 30px top/bottom, auto left/right for centering */
    padding-top: 20px;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.question-container h2 {
    color: #000000;
    font-size: 1.2em;
    font-weight: 700;
    text-align: center;
    margin-bottom: 25px;
    letter-spacing: 0.01em;
}

.question-form,
.question-container form {
    width: 85%;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.question-container form > div {
    background: #EEE4DE;
    border-radius: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    min-height: 48px; /* Ensures enough height for radio and text */
    user-select: none; /* Prevents text selection when clicking */
    transition: all 0.3s ease;
}

.question-container form > div.selected,
.question-container form > div:has(input:checked) {
    border: 2px solid #833909;
    background: #EEE4DE;
    box-shadow: 0 2px 8px rgba(26, 53, 87, 0.15);
}

.question-container input[type="radio"] {
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid #833909;
    border-radius: 50%;
    margin-left: 18px;
    margin-right: 15px;
    background: #fff;
    outline: none;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    flex-shrink: 0; /* Prevents the radio from shrinking */
    margin-top: 0;
    margin-bottom: 0;
}

.question-container input[type="radio"]:checked {
    border: 6px solid #833909;
    background: #fff;
}

.question-container form > div label,
.question-container form > div {
    font-size: 0.95em;
    color: #000000;
    font-weight: 450;
    cursor: pointer;
    width: 95%;
    padding-right: 10px;
    background-color: #ffffff;
    border: 1px solid #833909;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    outline: none;
}

.question-container form > div:selected {
    background-color: #EEE4DE;
}

.question-container form > div:focus,
.question-container form > div:focus-within {
    outline: none;
    background-color: #EEE4DE;
}

.question-container input[type="radio"]:focus {
    outline: none;
    box-shadow: none;
}

.progress-indicator {
    color: #833909;
    font-size: 1.1em;
    font-weight: 500;
    text-align: center;
    margin-top: 0px;
    margin-bottom: 10px;
    opacity: 0.2;
    letter-spacing: 0.05em;
}

.btn {
    background: #833909;
    color: #fff;
    font-size: 1.2em;
    font-weight: 700;
    font-family: "Montserrat", Arial, sans-serif;
    border: none;
    border-radius: 10px;
    padding: 14px 0;
    width: 180px;
    margin: 10px auto 10px auto;
    display: block;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(26, 53, 87, 0.08);
    transition: background 0.2s, color 0.2s;
}

.btn:hover,
.btn:focus {
    background: #6b2d0a;
    color: #fff;
}

.btn:disabled {
    background: #EEE4DE;
    color: #833909;
    cursor: not-allowed;
}

.progress-indicator {
    color: #833909;
    font-size: 1.1em;
    font-weight: 500;
    text-align: center;
    opacity: 0.7;
    letter-spacing: 0.05em;
}

/* Q4 Result Card Styles */
#q4-result {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: none;
    box-shadow: none;
}

.result-card {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(26, 53, 87, 0.13);
    border: 10px solid #EEE4DE;
    width: 65%;
    padding-top: 40px;
    padding-bottom: 45px;
    padding-left: 25px;
    padding-right: 25px;
    max-width: 420px;
    text-align: center;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-card p {
    margin-top: 15px;
}

.result-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #833909;
    margin-bottom: 12px;
    font-family: "Montserrat", Arial, sans-serif;
}

.result-main {
    font-size: 2.5rem;
    font-weight: 800;
    color: #833909;
    margin-bottom: 16px;
    font-family: "Montserrat", Arial, sans-serif;
}

.result-sub {
    font-size: 1.1rem;
    font-weight: 700;
    color: #222;
    font-family: "Montserrat", Arial, sans-serif;
    margin-top: 15px;
    margin-bottom: 0px;
}

.result-desc {
    font-size: 1.15rem;
    font-weight: 400;
    color: #222;
    line-height: 1.5;
    font-family: "Montserrat", Arial, sans-serif;
}

.result-btn {
    background: #833909;
    color: #fff;
    font-size: 1.1rem;
    height: 52px;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    padding: 12px 22px;
    margin-top: 10px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(35, 64, 110, 0.08);
    transition: background 0.2s, transform 0.1s;
    font-family: "Montserrat", Arial, sans-serif;
}

.result-btn:hover {
    background: #833909;
    transform: translateY(-2px) scale(1.03);
}

/* Animal Ally Result Page Styles */
#animal-ally-result {
    display: block;
    min-height: 100vh;
    width: 100vw;
    position: relative;
    overflow-y: auto; /* enables scrolling if content is too tall */
}

#animal-ally-result h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: black;
    text-align: center;
}

#animal-ally-result h3 {
    display: block;
    font-size: 2em;
    font-weight: 800;
    color: #833909;
    margin-top: 0;
    margin-bottom: 0;
    text-align: center;
}

#animal-ally-result img {
    display: block;
    margin: 10px auto 16px auto;
    width: 150px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(35, 64, 110, 0.1);
}

#animal-ally-result h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #833909;
    text-align: left;
    margin-top: 8px;
    margin-bottom: 8px;
}

#animal-ally-result p {
    font-size: 1.08rem;
    color: #000000;
    line-height: 1.4;
    text-align: left;
    margin-top: 8px;
    margin-bottom: 8px;
}

#animal-ally-result p b {
    font-weight: 700;
    color: #833909;
}

#animal-ally-result .animal-description {
    font-size: 1.08rem;
    color: #000000;
    line-height: 1.4;
    text-align: left;
    margin-top: 8px;
    margin-bottom: 8px;
}

#animal-ally-result {
    background: none;
}

#animal-ally-result {
    /* Center the card */
    width: 100vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#animal-ally-result > h2,
#animal-ally-result > h4,
#animal-ally-result > p,
#animal-ally-result > img,
#animal-ally-result > button {
    z-index: 2;
}

#animal-ally-result::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #DBC8BD;
    z-index: 0;
}

#animal-ally-result {
    position: relative;
}

#animal-ally-result .animal-card {
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(26, 53, 87, 0.13);
    border: 10px solid #EEE4DE;
    padding: 20px 30px 40px 30px;
    max-width: 420px;
    width: 70%;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}

#animal-ally-result .animal-card {
    align-items: flex-start;
}

#animal-ally-result .animal-card p {
    width: 100%;
    text-align: left;
}

#animal-ally-result .animal-card h2,
#animal-ally-result .animal-card h3 {
    align-self: center;
    text-align: center;
    width: 100%;
}

#animal-ally-result .animal-card p,
#animal-ally-result .animal-card h4 {
    align-self: flex-start;
    text-align: left;
    width: 100%;
}

#animal-ally-result button.btn {
    background: #833909;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    font-family: "Montserrat", Arial, sans-serif;
    border: none;
    border-radius: 10px;
    margin-top: 18px;
    margin-bottom: 0;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(35, 64, 110, 0.08);
    transition: background 0.2s, transform 0.1s;
    width: 180px;
    height: 52px;
    display: block;
}

#animal-ally-result button.btn#retake-quiz-btn {
    background: #DBC8BD;
    margin-top: 14px;
    margin-bottom: 0;
    border: none;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(35, 64, 110, 0.06);
}

#animal-ally-result button.btn#retake-quiz-btn:hover {
    background: #ffffff;
    color: #833909;
}

#animal-ally-result button.btn:hover {
    background: #833909;
    color: #DBC8BD;
    transform: translateY(-2px) scale(1.03);
}

#controls-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 200px;
    height: 70px;
    background: rgb(214 214 214 / 50%);
    border-radius: 40px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    gap: 70px;
}

/* Game Over Overlay Styles */
.game-over-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(26, 53, 87, 0.13);
    border: 10px solid #DBC8BD;
    padding: 32px auto 32px auto;
    width: 250px;
    text-align: center;
}

.game-over-title {
    font-size: 2rem;
    font-weight: 700;
    color: #833909;
    margin-bottom: 5px;
    margin-top: 30px;
}

.game-over-score {
    font-size: 2.5rem;
    font-weight: 800;
    color: #833909;
    margin-bottom: 5px;
    font-family: "Montserrat", Arial, sans-serif;
}

.game-over-container button {
    margin-top: 0px;
    margin-bottom: 0px;
}

.game-over-highest-score {
    font-size: 14px;
    color: #833909;
    margin-bottom: 20px;
    font-family: "Montserrat", Arial, sans-serif;
}

.game-over-container button:last-child {
    margin-bottom: 40px;
}

.game-over-container button {
    color: #fff !important;
    font-family: "Montserrat", Arial, sans-serif;
}

/* Leaderboard Overlay Styles */

#leaderboard-overlay h2 {
    color: #833909;
    text-align: center;
    margin-bottom: 15px;
    margin-top: 5px;
    font-weight: 750;
    font-size: 1.7rem;
}

#leaderboard-overlay th {
    color: #833909;
    padding: 8px;
    text-align: left;
    border-bottom: 1.5px solid #DBC8BD;
    font-size: 1rem;
    font-weight: 700;
    color: #833909;
    text-align: center;
    height: 20px;
}

#leaderboard-overlay th:nth-child(1),
#leaderboard-overlay th:nth-child(2) {
    width: 26px;
}
#leaderboard-rows td:nth-child(1),
#leaderboard-rows td:nth-child(2) {
    padding: 3px;
}

#leaderboard-rows td:nth-child(1) {
    padding-top: 3px;
}
#leaderboard-overlay th:nth-child(3) {
    width: 65px;
}
#leaderboard-overlay th:nth-child(4) {
    width: 55px;
}

#leaderboard-rows {
    font-size: 1rem;
    font-weight: 400;
    color: #000000;
    text-align: center;
}

#leaderboard-rows td {
    padding: 6px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
    height: 50px;
}
#leaderboard-rows td:nth-child(3) {
    max-width: 80px;
    font-size: 1rem;
}
#leaderboard-rows td:nth-child(3).long-name {
    font-size: 0.8rem;
}
#leaderboard-rows td:nth-child(3).very-long-name {
    font-size: 0.7rem;
}
#leaderboard-rows td:nth-child(4) {
    max-width: 60px;
    font-size: 1rem;
}
#leaderboard-rows td:nth-child(4).long-score {
    font-size: 0.9rem;
}
#leaderboard-rows td:nth-child(4).very-long-score {
    font-size: 0.7rem;
}

#leaderboard-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.leaderboard-container {
    background: white;
    padding: 25px;
    border-radius: 20px;
    max-width: 290px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 20px;
    border: 10px solid #DBC8BD;
}

.leaderboard-container table {
    width: 100%;
    table-layout: fixed;
}

/* Opt-in checkbox container styles */
.opt-in-container {
    margin: 5px 10 15px 0;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
}

.opt-in-checkbox {
    margin: 2px 0 0 0;
    width: 24px;
    height: 24px;
    accent-color: #833909;
}

#register-page .opt-in-label {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    text-align: left;
    color: #000000;
    font-weight: 400;
}
